home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 April
/
EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso
/
EARCD
/
comm
/
thor
/
thor24arexx.lha
/
CygnusEd
/
CEDDownload.thor
< prev
next >
Wrap
Text File
|
1996-11-11
|
3KB
|
160 lines
/* CEDDownload.thor · by Troels Walsted Hansen
** $VER: CEDDownload.thor v2.00 (15.09.94)
**
** An ARexx script that creates a download event for the file
** under the cursor in CED.
**
** Get-file-name code is a slightly modified version of
** something I found in insert_adr.ced by Dirk Federlein. :^)
**
** New: This version is for THOR v2.0 or higher.
*/
/* user variables. edit to your hearts content */
bbsname = "REQUEST" /* Change REQUEST to a BBS name if you like.. */
/* needs THOR, bbsread.library, CED and rexxsupport.library functions */
options results
p = ' ' || address() || ' ' || show('P',,)
thorport = pos(' THOR.',p)
if thorport > 0 then thorport = word(substr(p,thorport+1),1)
else
do
say 'No THOR port found!'
exit 10
end
if ~show('p', 'BBSREAD') then
do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
end
if ~show('ports','rexx_ced') then do
say "Sorry, CED's ARexx port was not found. Aborting script.."
exit
end
if ~show(l, 'rexxsupport.library') then do
if ~addlib('rexxsupport.library', 0, -30) then do
say "Please install rexxsupport.library in your libs: directory"
exit
end
end
address 'rexx_ced'
/* get filename */
tabchar = '09'X
cr = '0A'X
/* Get contents of current line: */
status 55
line = result
/* Get tab size: */
status 8
tabadjust = result - 1
/* Get cursor x position (relative to beginning of line = 1): */
status 46
cur = result + 1
i = index(line,tabchar)
DO while i > 0 & i <= cur - tabadjust
cur = cur - tabadjust
i = index(line,tabchar,i+1)
END
/* If the current character is non-alphabetic, then start one character
** over to the left. This allows the cursor to be immediately after
** the key word (say on a space or bracket.)
*/
char = substr(line,cur,1)
if (~(datatype(char,'A') | char = '.' | char = '-' | char = '_' | char = '+') & cur > 1) then
cur = cur - 1
/* Find leftmost and rightmost alphabetic character adjacent to current: */
right = cur - 1
left = cur + 1
char = 'A'
DO while (datatype(char,'A') | char = '.' | char = '-' | char = '_' | char = '+') & (left > 0)
left = left - 1
if left > 0 then
char = substr(line,left,1)
END
char = 'A'
DO while (datatype(char,'A') | (char = '.' | char = '-' | char = '_' | char = '+'))
right = right + 1
char = substr(line,right,1)
END
if right-left <= 1 then
DO
address(thorport)
THORTOFRONT
REQUESTSTRING TITLE '"Enter name of file to download:"' BT '"_Ok|_Cancel"' MAXCHARS 40
if(rc ~= 0) then
do
address 'rexx_ced'
CEDTOFRONT
exit
end
end
else
do
EVENT.FILENAME = substr(line,left+1,right-left-1)
end
/* create upload event */
address(thorport)
if(BBSname = "REQUEST") then do
address(bbsread)
GETBBSLIST stem BBSLIST
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
exit 5
end
address(thorport)
THORTOFRONT
REQUESTLIST instem BBSLIST title '"Select BBS:"' SIZEGADGET
if(rc ~= 0) then
do
address 'rexx_ced'
CEDTOFRONT
exit
end
else bbs = result
end
address(bbsread)
WRITEBREVENT '"'bbs'"' event 4 stem EVENT
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
exit 5
end
/* bye.. */
address 'rexx_ced'
CEDTOFRONT
exit